#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
//https://www.luogu.com.cn/problem/P8218
using namespace std;
const int N = 1e5 + 10;
int n, m;
int f[N];

int main()
{
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		cin >> f[i];
		f[i] += f[i - 1];
	}


	cin >> m;
	while (m--)
	{
		int l, r;
		cin >> l >> r;
		cout << f[r] - f[l - 1] << endl;
	}

	return 0;
}